package com.example.demo.service.impl;

import com.example.demo.dbo.User;
import com.example.demo.event.OrderEvent;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: demo
 * @description:
 * @author: Mr.Wang
 * @create: 2020-04-28 11:14
 **/
@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper uerMapper;
    @Autowired
    private ApplicationContext applicationContext;

    @Override
    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public void addData(User user) {
        //uerMapper.insert(user);
        uerMapper.updateByPrimaryKey(user);
        //OrderEvent orderEvent = new OrderEvent(user);
        //applicationContext.publishEvent(orderEvent);
        System.out.println("进来了");
    }

    @Override
    public String del(String key) {
        return "返回成功";
    }

    public static String remove(String key) {
        log.info("ognl -----------------------{}",key);
        return key;
    }


    public static void main(String[] args) {
        int i = 1;
        byte m =(byte) i;
        System.out.println(m);
    }
}
